<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<!-- 
		Replace path to template, title, header and body
		with actual data.
	 -->
<ui:composition template="/template/template.xhtml">
	<ui:define name="pageTitle">Cadastro de Fornecedo</ui:define>
	<ui:define name="pageHeader">Fornecedo</ui:define>
	<ui:define name="body">
		<h1>Cadastro de Fornecedores</h1>
		<h:form id="edicao">
			<h:messages />
			<h:inputHidden value="#{fornecedoBean.fornecedo.fornecedo}" />

			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:" />
				<h:inputText id="nomeFornecedo"
					value="#{fornecedoBean.fornecedo.nome}" />

				
				<h:outputLabel value="CNPJ:" />
				<h:inputText id="CNPJFornecedo"
					value="#{fornecedoBean.fornecedo.cnpj}" />
				<h:outputLabel value="E-Mail:" />
				
			</h:panelGrid>
			<h:commandButton value="Salvar" action="#{fornecedoBean.salvar}" />
			<h:commandButton value="Novo Fornecedo"
				action="#{fornecedoBean.novo}" />



		</h:form>
		<h:messages />
		<h:form id="lista">
			<h:dataTable value="#{fornecedoBean.lista}" var="fornecedo"
				rules="rows" cellpadding="5">
				<f:facet name="header">Listagem de Fornecedores</f:facet>
				<f:facet name="footer">Final da Listagem</f:facet>
				<h:column>
					<f:facet name="header">Estado</f:facet>
					<h:commandLink action="#{fornecedoBean.ativar}">
						<h:graphicImage library="imagens"
							name="fabricante_ativo_#{fornecedo.flagAtiva}.png" style="borde:0" />
						<f:setPropertyActionListener target="#{fornecedoBean.fornecedo}"
							value="#{fornecedo}" />
					</h:commandLink>
				</h:column>
				<h:column>
					<f:facet name="header">Nome</f:facet>
                        #{fornecedo.nome}
                        </h:column>
				
				<h:column>
					<f:facet name="header">CNPJ</f:facet>
                        #{fornecedo.cnpj}
                        </h:column>
				
					
					<f:facet name="header">Ações</f:facet>
					<h:commandLink action="#{fornecedoBean.excluir}"
						onclick="if (!confirm('Deseja realmente excluir o fornecedo #{fornecedo.nome}?')) return false;">
						<h:graphicImage library="imagens" name="remove.png" />
						<f:setPropertyActionListener target="#{fornecedoBean.fornecedo}"
							value="#{fornecedo}" />
					</h:commandLink>
				
				<h:column>
					<h:commandLink action="#{fornecedoBean.editar}" value="">
						<h:graphicImage library="imagens" name="edita.jpg" style="borde:0" />
						<f:setPropertyActionListener target="#{fornecedoBean.fornecedo}"
							value="#{fornecedo}" />
					</h:commandLink>
				</h:column>
			</h:dataTable>
		</h:form>
	</ui:define>
</ui:composition>


</html>